#!/usr/bin/perl -al

package wrapCORE;

sub import {
    my $callpkg = shift;
    return unless @_;

    *{"main::abs"} = \&{"main::abs"};

    eval q{
        package main;
        sub abs {
            my $arg = shift;
            print ">>> abs($arg) called";
            return $arg;
        }
    };

    our $code = q{
        sub {
            local($", $!) = (', ', 0);
            print "*** wrapper called";
            return &$sref(@_);
        }
    };
    $code = eval "$code;";

    $sref = \&{'main::abs'};
    *{'main::abs'} = $code;
}

sub unimport {
    import(@_);
    *{'main::abs'} = $sref;
}

1;
